#pragma once
std::string convertHex(fastring str);
std::string convertHex(unsigned char* data, int count);

class FSMap
{
public:
	bool Load(const char* filePath);
	void SaveMapPng(const char* filePath, std::vector<cv::Vec3b> &masks);

	struct Sprite
	{
		uint32_t widht;
		uint32_t height;
		uint32_t data_size;
		uint8_t* data;
		cv::Mat image;
	};

	struct Adorn
	{
	public:
		uint8_t index;
		uint32_t width;
		uint32_t height; 
		uint8_t* szPalette;//0x300
		uint8_t* data1;
		uint64_t* data2;
		std::vector<Sprite> sprites;
		std::vector<cv::Point2i> offsets;
		cv::Mat image;
	};


	static void ConvertImage(Sprite &sprite, uint8_t* szPalette);
	static void ConvertImage2(Sprite& sprite, uint8_t* szPalette);
	void ConvertImageShadow(Sprite& sprite, uint8_t* szPalette, std::vector<cv::Vec3b>& masks);


private:
	std::vector<uint8_t> m_data;
	uint32_t m_width;
	uint32_t m_height;
	uint8_t* m_collision;
	uint16_t* m_map_color_tiles;
	uint16_t* m_map_shadow_tiles;
	uint16_t* m_map_adorn_tiles;
	std::vector<Sprite> m_tile_color_data;
	std::vector<Sprite> m_tile_shadow_data;
	std::vector<Adorn> m_tile_adorn_data;
	uint8_t* m_palette;
};

